home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / FindIcon / Get1IconSuite.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-05  |  1.3 KB  |  51 lines  |  [TEXT/KAHL]

  1. #include <exceptions.h>
  2. #include "Get1IconSuite.h"
  3.  
  4. /*    --------------------------------------------------------------------
  5.     Get1IconSuite            Like GetIconSuite, but only looks in
  6.                             the current resource file.
  7.     
  8.     In case you're wondering why it would be necessary to ensure that
  9.     icons come from only one file, suppose you're looking at a
  10.     file that has its custom icon bit set, but for some reason does
  11.     not contain a custom icon, or at least not a full family.
  12.     Way down the resource chain, there may be another file, say a
  13.     font file, that does have a full family of custom icons. 
  14.     So you get an unexpected icon.
  15.     --------------------------------------------------------------------
  16. */
  17.  
  18. static pascal OSErr Get_1_icon(
  19. /* --> */    ResType the_type,
  20. /* <-> */    Handle *the_icon,
  21. /* --> */    short    *res_id );
  22.  
  23.  
  24. pascal OSErr Get1IconSuite(
  25. /* <-- */    Handle *theSuite,
  26. /* --> */    short theID,
  27. /* --> */    long theSelector
  28. )
  29. {
  30.     OSErr        err;
  31.     
  32.     err = NewIconSuite( theSuite );
  33.     forbid( err, NewIconSuite );
  34.     
  35.     err = ForEachIconDo( *theSuite, theSelector,
  36.         (IconAction) Get_1_icon, &theID );
  37.     
  38. NewIconSuite:
  39.     return err;
  40. }
  41.  
  42. static pascal OSErr Get_1_icon(
  43. /* --> */    ResType the_type,
  44. /* <-> */    Handle *the_icon,
  45. /* --> */    short    *res_id )
  46. {
  47.     *the_icon = Get1Resource( the_type, *res_id );
  48.     
  49.     return noErr;
  50. }
  51.